package com.cbank.controller.pc;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.cbank.service.ModuleShowService;
import com.cbank.vo.ModuleVo;
import com.cbank.domain.ModuleShow;

@Controller
@RequestMapping("/")
public class WebController {
	@Autowired
    private ModuleShowService moduleShowService;
	
	Logger logger = Logger.getLogger(WebController.class);

	@RequestMapping(value = "", method = RequestMethod.GET)
	public String index(Model model) {
		logger.info("---------welcome--------index");
		List<ModuleShow> imageList=this.moduleShowService.getListByModuleIdAndType(1,ModuleShow.TYPE_GG);
		Collections.sort(imageList, new Comparator<ModuleShow>() {
			@Override
			public int compare(ModuleShow o1, ModuleShow o2) {
				return o2.getId()-o1.getId();
			}
		});
        List<ModuleShow> moduleShowList=this.moduleShowService.getListByModuleIdAndType(1,ModuleShow.TYPE_CON);
        ModuleVo moduleVo=new ModuleVo();
        moduleVo.setModuleShowList(moduleShowList);
        moduleVo.setImageList(imageList);
        model.addAttribute("moduleVo",moduleVo);
		return "/pc/show";
	}
}
